package com.artron.mediaartron.data.config;

import android.content.Context;

import com.artron.mediaartron.data.greendao.DaoMaster;
import com.artron.mediaartron.data.greendao.DaoMaster.DevOpenHelper;
import com.artron.mediaartron.data.greendao.DaoSession;


/**
 * 作者：EasonCheng on 2017/8/24 16:42
 * 邮箱：chengqi@artron.net
 */

public class DbConfig {

    private static DbConfig sConfig = null;

    private DaoSession mDaoSession;
    private DbConfig(Context context){
        DevOpenHelper helper = new DevOpenHelper(context, "notes-db", null);
        DaoMaster daoMaster = new DaoMaster(helper.getWritableDatabase());
        mDaoSession = daoMaster.newSession();
    }

    public static DbConfig newInstance(Context context) {
        if (sConfig == null) {
            synchronized (DbConfig.class) {
                if (sConfig == null) {
                    sConfig = new DbConfig(context);
                }
            }
        }
        return sConfig;
    }

    DaoSession getDaoSession() {
        return mDaoSession;
    }
}
